
//添加开通地区
function add() {
	//时间
	var provinceCode = $('#province .opts .selected').attr("val");
    var provinceName = $('#province .opts .selected').html();
    var cityCode = $('#city .opts .selected').attr("val");
    var cityName = $('#city .opts .selected').html();
    var areaCode = $('#area .opts .selected').attr("val");
    var areaName = $('#area .opts .selected').html();

	if (areaCode=='' || areaCode==undefined || areaCode=='undefined') {
            alert('请选择完整地区');
            return;
	}

    if (provinceName.indexOf("市") > -1 || provinceName.indexOf("香港") > -1 || provinceName.indexOf("澳门") > -1) {
        cityName = provinceName;
    }
	
    $.ajax({
        url:  urlcore + "/api/openArea/addArea",
       		type: "post",
       		data:JSON.stringify(
       			{
	            "areaCode": areaCode,
	            "status":0,
	            "province": provinceName,
	            "city": cityName,
	            "area": areaName
       			}),
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success:function(data){
				if (data.success == true) {             
                    if (confirm("添加成功，是否继续添加？")) {
                        //刷新
                        location.reload();
                    } else {
                        //跳转列表页
                        window.location.href = "openarea_list.html";
                    }	                   
                }
             else if (data.code == 'OVERTIME') {
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href = "login.html";
                }
            } else {
                alert(data.msg);
            }

        },
        error: function() {
            alert("error");
        }

    });
}

